/*     */ package com.infoservice.schedule.generator;
/*     */ 
/*     */ import com.infoservice.schedule.Constant;
/*     */ import com.infoservice.schedule.po.pos.TaskPO;
/*     */ import com.infoservice.schedule.util.TaskUtils;
/*     */ import java.util.Calendar;
/*     */ import java.util.Date;
/*     */ 
/*     */ public class GenMonthTask extends TaskGenerator
/*     */ {
/*     */   public GenMonthTask(TaskPlanInfo tpInfo, TaskPO tk)
/*     */   {
/*  35 */     super(tpInfo, tk);
/*     */   }
/*     */ 
/*     */   public long getDelayTime()
/*     */   {
/*  43 */     Date nextTime = getNextExcTime();
/*  44 */     Calendar cur = TaskUtils.getCalendar();
/*  45 */     return nextTime.getTime() - cur.getTimeInMillis() < Constant.TASK_GEN_AHEAD_TIME ? 0L : nextTime.getTime() - cur.getTimeInMillis() - Constant.TASK_GEN_AHEAD_TIME;
/*     */   }
/*     */ 
/*     */   public long getPeriodTime()
/*     */   {
/*  54 */     return getInterval();
/*     */   }
/*     */ 
/*     */   public void run()
/*     */   {
/*  62 */     genTask();
/*     */   }
/*     */ 
/*     */   public Date getNextExcTime()
/*     */   {
/*  70 */     Calendar cur = TaskUtils.getCalendar();
/*  71 */     Date planStartTime = null;
/*  72 */     if (this.tk == null) {
/*  73 */       Calendar start = TaskUtils.getCalendar();
/*  74 */       String[] startTime = this.tpInfo.getPlanStart().split(":");
/*  75 */       start.set(11, Integer.parseInt(startTime[0]));
/*  76 */       start.set(12, Integer.parseInt(startTime[1]));
/*     */ 
/*  78 */       String mday = this.tpInfo.getPlanPattern();
/*  79 */       if (mday.equals("M0")) {
/*  80 */         start.set(5, start.getActualMinimum(5));
/*     */       }
/*  82 */       if (mday.equals("M30")) {
/*  83 */         start.set(5, start.getActualMaximum(5));
/*     */       }
/*  85 */       planStartTime = start.getTime();
/*  86 */       if (planStartTime.getTime() >= cur.getTimeInMillis())
/*  87 */         return planStartTime;
/*     */     } else {
/*  89 */       planStartTime = this.tk.getPlanStartTime();
/*  90 */       if (planStartTime.getTime() >= cur.getTimeInMillis()) {
/*  91 */         return new Date(planStartTime.getTime() + getInterval());
/*     */       }
/*     */     }
/*  94 */     int times = (int)((cur.getTimeInMillis() - planStartTime.getTime()) / getInterval());
/*  95 */     times++;
/*  96 */     return new Date(planStartTime.getTime() + times * getInterval());
/*     */   }
/*     */ 
/*     */   public long getInterval()
/*     */   {
/* 103 */     long days = TaskUtils.getCalendar().getActualMaximum(5);
/* 104 */     return days * 86400000L;
/*     */   }
/*     */ 
/*     */   public void removeTaskPlan()
/*     */   {
/* 111 */     cancel();
/*     */   }
/*     */ 
/*     */   public int getIgnoreTimes()
/*     */   {
/* 119 */     Calendar cur = TaskUtils.getCalendar();
/* 120 */     Date planStartTime = null;
/* 121 */     if (this.tk == null) {
/* 122 */       Calendar start = TaskUtils.getCalendar();
/* 123 */       String[] startTime = this.tpInfo.getPlanStart().split(":");
/* 124 */       start.set(11, Integer.parseInt(startTime[0]));
/* 125 */       start.set(12, Integer.parseInt(startTime[1]));
/*     */ 
/* 127 */       String mday = this.tpInfo.getPlanPattern();
/* 128 */       if (mday.equals("M0")) {
/* 129 */         start.set(5, start.getActualMinimum(5));
/*     */       }
/* 131 */       if (mday.equals("M30")) {
/* 132 */         start.set(5, start.getActualMaximum(5));
/*     */       }
/* 134 */       planStartTime = start.getTime();
/* 135 */       if (cur.getTimeInMillis() < planStartTime.getTime()) {
/* 136 */         return 0;
/*     */       }
/* 138 */       long times = (cur.getTimeInMillis() - planStartTime.getTime()) / getInterval();
/* 139 */       return (int)times + 1;
/*     */     }
/*     */ 
/* 142 */     planStartTime = this.tk.getPlanStartTime();
/* 143 */     if (cur.getTimeInMillis() < planStartTime.getTime()) {
/* 144 */       return 0;
/*     */     }
/* 146 */     long times = (cur.getTimeInMillis() - planStartTime.getTime()) / getInterval();
/* 147 */     return (int)times;
/*     */   }
/*     */ 
/*     */   public void setTaskPO(Date planStartTime)
/*     */   {
/* 157 */     if (this.tk == null) {
/* 158 */       this.tk = new TaskPO();
/*     */     }
/* 160 */     this.tk.setPlanStartTime(planStartTime);
/*     */   }
/*     */ 
/*     */   public Date getEndDate()
/*     */   {
/* 168 */     String[] end = this.tpInfo.getPlanEnd().split(":");
/* 169 */     Calendar cur = TaskUtils.getCalendar();
/* 170 */     cur.set(11, Integer.parseInt(end[0]));
/* 171 */     cur.set(12, Integer.parseInt(end[1]));
/* 172 */     String mday = this.tpInfo.getPlanPattern();
/* 173 */     if (mday.equals("M0")) {
/* 174 */       cur.set(5, cur.getActualMinimum(5));
/*     */     }
/* 176 */     if (mday.equals("M30")) {
/* 177 */       cur.set(5, cur.getActualMaximum(5));
/*     */     }
/* 179 */     return cur.getTime();
/*     */   }
/*     */ 
/*     */   public Date getStartDate()
/*     */   {
/* 188 */     String[] end = this.tpInfo.getPlanStart().split(":");
/* 189 */     Calendar cur = TaskUtils.getCalendar();
/* 190 */     cur.set(11, Integer.parseInt(end[0]));
/* 191 */     cur.set(12, Integer.parseInt(end[1]));
/* 192 */     String mday = this.tpInfo.getPlanPattern();
/* 193 */     if (mday.equals("M0")) {
/* 194 */       cur.set(5, cur.getActualMinimum(5));
/*     */     }
/* 196 */     if (mday.equals("M30")) {
/* 197 */       cur.set(5, cur.getActualMaximum(5));
/*     */     }
/* 199 */     return cur.getTime();
/*     */   }
/*     */ }

/* Location:           D:\Workspace\Work\ASMP_DE\lib\frame3\InfoSchedule_1.0.03.jar
 * Qualified Name:     com.infoservice.schedule.generator.GenMonthTask
 * JD-Core Version:    0.6.0
 */